﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;

/// <summary>
/// https://blog.csdn.net/pengsixiang/article/details/3620902
/// 
/// </summary>

namespace wd_18_system_log
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        string log_event = "wflog";
        public MainWindow()
        {
            InitializeComponent();

            if (!EventLog.SourceExists(log_event))
            {
                EventLog.CreateEventSource(log_event, "wflogger");  //不超过8个字符
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            EventLog.WriteEntry(log_event, "我的程序启动了666");
        }
    }
}
